<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<script src="https://www.zhengfy.top/jq.js"></script>
</head>

<textarea name="" id="" cols="100" rows="1" style="font-size:26px;border: 0;">
</textarea>
<hr>
<button onclick="wer()" style="width:100%;height:30px;">生成</button>
<br>
<br>
<span style="display:inline-block;width:70px;    text-align: right;">a-z</span>
<input id="xiao" type="checkbox" checked="checked">
<br>
<br>
<span style="display:inline-block;width:70px;    text-align: right;">A-Z</span>
<input id="da" type="checkbox">
<br>
<br>
<span style="display:inline-block;width:70px;    text-align: right;">0-9</span>
<input id="num" type="checkbox" checked="checked">
<br>
<br>
<span style="display:inline-block;width:70px;    text-align: right;">特殊</span>
<input id="qi" type="checkbox">
<br>
<br>
<span style="display:inline-block;width:70px;    text-align: right;">长度</span>
<input id="lang" type="text" value="30">
<br>
<br>
<hr>
<div name="" id="we" style="font-size:26px" border="1">
</div>

<script>
	var sre = "";
	for (var y = 0; y < 5; y++) {
		sre += "" + Math.random().toString(36).substr(2) + "";
	}
	$("textarea").html(sre);

	wer();

	function wer() {
		var arr = [];
		var arr1 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
		var arr2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
		var arr3 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
		var arr4 = ["{", "}", "[", "]", "?", "!", "<", ">", "*", "(", ")", "&", "^", "%", "$", "@", "!", "~"];
		if ($("#num").prop('checked') == true) {
			arr = [...arr, ...arr1];
		}
		if ($("#da").prop('checked') == true) {
			arr = [...arr, ...arr3];
		}
		if ($("#xiao").prop('checked') == true) {
			arr = [...arr, ...arr2];
		}
		if ($("#qi").prop('checked') == true) {
			arr = [...arr, ...arr4];
		}
		var f = randomWord(false, $("#lang").val(), $("#lang").val(), arr);
		$("#we").html(f);
	}

	function randomWord(randomFlag, min, max, arr) {
		var str = "",
			range = min;
		// 随机产生
		// if (randomFlag) {
		// 	range = Math.round(Math.random() * (max - min)) + min;
		// }
		for (var i = 0; i < range; i++) {
			pos = Math.round(Math.random() * (arr.length - 1));
			str += arr[pos];
		}
		return str;
	}
</script>

</html>